package com.breeze.components.core.exception.error;

import cn.hutool.core.lang.Assert;
import com.breeze.components.core.exception.ApiException;
import java.util.Collection;

/**
 * 错误码顶级接口
 *
 * @author breeze
 */
public interface ErrorCodeInterface {

  /**
   * 返回错误码
   *
   * @return 错误码
   */
  int code();

  /**
   * 返回具体的详细错误描述
   *
   * @return 错误描述
   */
  String message();

  default void notNull(Object obj) {
    Assert.notNull(obj, () -> new ApiException(this));
  }

  default void notNull(Object obj, Object... args) {
    Assert.notNull(obj, () -> new ApiException(this, args));
  }

  default void equals(Object obj1, Object obj2) {
    Assert.equals(obj1, obj2, () -> new ApiException(this));
  }

  default void notEquals(Object obj1, Object obj2, Object... args) {
    Assert.notEquals(obj1, obj2, () -> new ApiException(this, args));
  }

  default void notEquals(Object obj1, Object obj2) {
    Assert.notEquals(obj1, obj2, () -> new ApiException(this));
  }

  default <T> void notEmpty(Collection<T> records) {
    Assert.notEmpty(records, () -> new ApiException(this));
  }

  default void isFalse(Boolean bool) {
    Assert.isFalse(bool, () -> new ApiException(this));
  }

  default void isFalse(Boolean bool, Object... args) {
    Assert.isFalse(bool, () -> new ApiException(this, args));
  }

  default void isTrue(Boolean bool) {
    Assert.isTrue(bool, () -> new ApiException(this));
  }

  default void isTrue(Boolean bool, Object... args) {
    Assert.isTrue(bool, () -> new ApiException(this, args));
  }

  default void isNull(Object obj) {
    Assert.isNull(obj, () -> new ApiException(this));
  }

  default void notEmpty(String content) {
    Assert.notEmpty(content, () -> new ApiException(this));
  }
}
